<script type="text/javascript" src="<?php echo base_url()?>js/admins/post.js"></script>
<style>
	.underline{
		text-decoration: underline;
	}
	a:hover {
		color: #FF4400;
	}
</style>
<!-- phần nội dung quản lý - bên phải -->
<div id="content-right" style="width: 100%;">
	<input type="hidden" name="base_url" id="base_url" value="<?php echo base_url();?>" />
	<div id="add-product">
		<div id="sidebar-list" class="black">
			<div id="img-product" class="left white">
				 <?php echo $title?>
			</div>
			<div id="img-back" class="right">
				<a href="javascript:;" onclick="history.go(-1)" class="white">Quay lại trang trước </a>
			</div>
			<div class="clear">
			</div>
		</div>
		<div id="src-product" style="height:auto;">
			<form action="<?php echo base_url()?>admins/admin_product/search" method="post">
				<input type="hidden" name="base_url" id="base_url" value="<?php echo base_url();?>" />
				<table>
					<tr>
						<td>
							<select name="select_id" style="width: 180px; border: 1px solid #CCC; padding: 1px; height: 24px;">
								<option value="">== Tìm kiếm theo ==</option>
								<option value="1" <?php if(!empty($_SESSION['select_id'])){if($_SESSION['select_id']==1) echo 'selected="selected"';}?>>Tiêu đề</option>
								<option value="2" <?php if(!empty($_SESSION['select_id'])){if($_SESSION['select_id']==2) echo 'selected="selected"';}?>>ID</option>
								<option value="3" <?php if(!empty($_SESSION['select_id'])){if($_SESSION['select_id']==3) echo 'selected="selected"';}?>>Keyword</option>
							</select>
						</td>
						<td><input type="text" name="name" placeholder="Nhập dữ liệu tương ứng" style="width: 200px; border: 1px solid #CCC; height: 24px;" <?php if(!empty($_SESSION['name'])){if($_SESSION['name'] != '0'){?> value='<?php echo $_SESSION['name'];?>' <?php }}?> /></td>
					</tr>
					<tr>
						<td>
							<select name="category_id" id="cat_id" style="width: 180px; border: 1px solid #CCC; padding: 1px; height: 24px;" onchange="GetSubCat();">
								<option value="">=== Chọn chuyên mục ====</option>
								<?php foreach ($cat1 as $c1){?>
									<option value="<?php echo $c1['id']?>" <?php if(!empty($_SESSION['category'])){if($_SESSION['category']==$c1['id']) echo 'selected=selected';}?>><?php echo ucfirst(mb_strtolower($c1['name'], 'UTF-8'))?></option>																					
								<?php }?>
							</select>
						</td>
						<td>
							<select name="subcat_id" id="subcat_id" style="width: 200px; border: 1px solid #CCC; padding: 1px; height: 24px;" onchange="GetSubSubCat();" disabled="disabled">
								<option value="">=== Chọn nhu cầu ====</option>								
							</select>
						</td>
						<td>
							<select name="subsubcat_id" id="subsubcat_id" style="width: 200px; border: 1px solid #CCC; padding: 1px; height: 24px;" disabled="disabled">
								<option value="">=== Chọn chủng loại ====</option>								
							</select>
						</td>
						<td>
							<select name="price_id" id="price_id" style="width: 200px; border: 1px solid #CCC; padding: 1px; height: 24px;" disabled="disabled">
								<option value="">=== Chọn giá ====</option>								
							</select>
						</td>
					</tr>
					<tr>
						<td>
							<select name="province_id" id="province_id" style="width: 180px; border: 1px solid #CCC; padding: 1px; height: 24px;" onchange="GetDistinct();">
								<option value="">=== Chọn nơi rao ===</option>	
								<?php foreach ($province as $prov){?>
									<option value="<?php echo $prov['id']?>"><?php echo $prov['name']?></option>
								<?php }?>							
							</select>
						</td>
						<td>
							<select name="distinct_id" id="distinct_id" style="width: 200px; border: 1px solid #CCC; padding: 1px; height: 24px;" disabled="disabled">
								<option value="">=== Chọn Quận/Huyện ====</option>								
							</select>
						</td>
						<td><input type="submit" class="submit-src" name="cmd" value=' ' /></td>
					</tr>
				</table>				
			</form>	
		</div>
		<form name="myform" id="myform" action="<?php echo base_url() ?>admins/admin_product/delete" method="POST" onSubmit="return checkInput(this,'Bạn hãy chọn ít nhất một tin','Bạn có chắc muốn xóa không?');">
			<div id="select-product">
				<ul class="left">
					<li><a href="<?php echo base_url()?>admins/admin_product/add">Thêm mới</a></li>
					<li> | </li>
					<li><a href="#"><span id="chk">0</span> đã chọn</a></li>
					<li> | </li>
					<li><input type="submit" name="cmd" value="Xóa"></li>
				</ul>
				<div class='clear'></div>
			</div>
			<div id="list-product">				
				<input type="hidden" id="chon" name="chon">
				<table id="myTable" class="tablePr tablesorter" width="100%" border="0" cellspacing="0" cellpadding="0">
					<thead>
						<tr class="headerTbl">
							<td width="3%">STT</td>
							<td width="3%"><input type="checkbox" name="chkall" value="yes" onClick="docheck(this.form,0);" /></td>
							<th width="20%">Tiêu Đề</th>
							<th width="15%">Danh Mục</th>							
							<th width="10%">Người tạo</th>							
							<th width="6%">Ngày tạo</th>
							<th width="6%">Ngày xuất bản</th>
							<th width="6%">Ngày kết thúc</th>
							<th width="5%">Views</th>
							<th width="3%">VIP</th>							
							<td width="5%">Action</td>
						</tr>
					</thead>
					<?php if (!empty($admin_products)){?>
						<tbody>
							<?php
								$i = 1; 
								foreach ($admin_products as $index) {
									if ($i % 2 == 0)
									{
										$bgcolor	= 'str1';
									}
									else
									{
										$bgcolor	= 'str2';
									}
							?>
							<tr class="<?php echo $bgcolor?>">
								<td><?php echo $i;?></td>
								<td><input type="checkbox" name="Xoa" value="<?php echo $index['id']?>" onClick="docheckone(this.form);"/></td>
								<td style="text-align: left;"><a href="<?php echo base_url()?>admins/admin_product/edit/<?php echo $index['id']?>" class=""><?php echo $index['title']?></a></td>
								<td style="text-align: left;">
									<?php 
										if (!empty($index['cat_1_id']))
										{
											$rs_cat	= $this->db->get_where('categories', array('id'=>$index['cat_1_id']))->row_array();
											if (!empty($rs_cat['id']))
											{
												echo '<a href="'.base_url().'admins/admin_product/search_category_article/'.$rs_cat['id'].'">'.$rs_cat['name'].'</a>';
											}
										}
										if (!empty($index['cat_2_id']))
										{
											$rs_cat2	= $this->db->get_where('categories', array('id'=>$index['cat_2_id']))->row_array();
											if (!empty($rs_cat2['id']))
											{
												echo '<br />&nbsp;&nbsp;&gt;&gt;&nbsp;<a href="'.base_url().'admins/admin_product/search_category2_article/'.$rs_cat2['id'].'">'.$rs_cat2['name'].'</a>';
											}
										}
										if (!empty($index['cat_3_id']))
										{
											$rs_cat2	= $this->db->get_where('categories', array('id'=>$index['cat_3_id']))->row_array();
											if (!empty($rs_cat2['id']))
											{
												echo '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&gt;&gt;&nbsp;<a href="'.base_url().'admins/admin_product/search_category2_article/'.$rs_cat2['id'].'">'.$rs_cat2['name'].'</a>';
											}
										}
									?>																										
								</td>   	
								<td style="text-align: left;">
									<?php
										if (!empty($index['user_id']))
										{
											$admin	= $this->db->get_where('users', array('id'=>$index['user_id']))->row_array();
											if (!empty($admin['email']))
											{
												echo '<a href="'.base_url().'admins/admin_admin/edit/'.$admin['id'].'">'.$admin['email'].'</a>';
											}
										}
									?>
								</td>
								<td><?php echo date('d/m/Y', $index['createdate']);?></td>
								<td><?php echo date('d/m/Y', $index['display_startdate']);?></td>
								<td><?php if (!empty($index['display_enddate'])) echo date('d/m/Y', $index['display_enddate']);?></td>
								<td><?php if (!empty($index['click'])) echo $index['click'];?></td>						                          
								<td>							
									<a href="<?php echo base_url()?>admins/admin_product/hot/<?php echo $index['id']?>/<?php echo $index['hot']?>">
										<?php if ($index['hot'] == 1){?>
											<img src="<?php echo base_url()?>images/back_end/icon/Check-icon.png" alt="checked" title="Tin thường" />
										<?php } else {?>
											<img src="<?php echo base_url()?>images/back_end/icon/un-check.png" alt="check" title="Tin HOT" />
										<?php }?>
									</a>
								</td>
								<td>							
									<a href="<?php echo base_url()?>admins/admin_product/edit/<?php echo $index['id']?>"><img width="16" height="16" src="<?php echo base_url()?>images/back_end/icon/edit-icon.png" title="Sửa tin tức <?php echo $index['title']?>" /></a>&nbsp;
									<a onclick="return confirm('Bạn có chắc chắn xóa tin bài: \n <?php echo $index['title']?> ?');" href="<?php echo base_url()?>admins/admin_product/delete/<?php echo $index['id']?>"><img width="16" height="16" src="<?php echo base_url()?>images/back_end/icon/icon_del.gif" title="Xóa tin bài <?php echo $index['title']?>" /></a>&nbsp;
									<a href="<?php echo base_url()?>admins/admin_product/active/<?php echo $index['id']?>/<?php echo $index['status']?>">
										<?php if ($index['status'] == 1){?>
											<img src="<?php echo base_url()?>images/back_end/icon/Check-icon.png" alt="checked" title="Ẩn tin tức <?php echo $index['title']?>" />
										<?php } else {?>
											<img src="<?php echo base_url()?>images/back_end/icon/un-check.png" alt="check" title="Kích hoạt tin tức <?php echo  $index['title']?>" />
										<?php }?>
									</a>
								</td>
							</tr>
							<?php $i++;}?>
						</tbody>
					<?php }else{?>
						<tr><td colspan="11" style="padding: 15px;">Không có dữ liệu</td></tr>
					<?php }?>
				</table>
			</div>
		</form>
		<div id="pagingPr"><?php echo $paging?></div> 
	</div>
</div><!-- end  content-right -->